package cn.xz.hibernatedemo.service.impl;

import cn.xz.hibernatedemo.mapper.UserRepository;
import cn.xz.hibernatedemo.pojo.User;
import cn.xz.hibernatedemo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserRepository userRepository;
    @Override
    public void insert(User user) {
        userRepository.save(user);
    }

    @Override
    public User queryOne(Integer id) {
        User user = userRepository.findById(id).get();
        return user;
    }

    @Override
    public List<User> queryAll() {
        return userRepository.findAll();
    }


}
